<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:63:"F:\yxl\tp5.com\public/../application/admin\view\nav\update.html";i:1561121519;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>layout 后台大布局 - Layui</title>
    <!--<link rel="stylesheet" href="./src/css/layui.css">-->
    <link rel="stylesheet" href="/static/layui/css/layui.css">
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">


    <div class="layui-body">
        <!-- 内容主体区域 -->
        <div style="padding: 15px;">修改</div>

        <form class="layui-form">
            <div class="layui-form-item">
                <input type="hidden" name="id"  value="<?php echo $data['id']; ?>" autocomplete="off" class="layui-input">
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">是否展示 </label>
                <div class="layui-input-block">
                    <input type="checkbox" id="is_visible" name="is_visible" value="<?php echo $data['is_visible']; ?>" lay-skin="switch">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">排序 </label>
                <div class="layui-input-block">
                    <input type="text" id="sort" name="sort" value="<?php echo $data['sort']; ?>" lay-skin="switch">
                </div>
            </div>
            <div class="layui-upload">
                <label class="layui-form-label">图片</label>
                <button type="button" class="layui-btn" id="test1">上传图片</button>
                <div class="layui-upload-list">
                    <div><img src="<?php echo $data['path_name']; ?>" style="padding-left:110px" class="layui-upload-img" id="demo1" width="150px" height="120px"></div>
                    <p id="demoText"></p>
                </div>
            </div>
            <input type="hidden" name="path_name" id="path_name">
            <div class="layui-upload">
                <label class="layui-form-label">按钮</label>
                <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
            </div>
        </form>
    </div>
</div>
<script src="/static/layui/layui.js"></script>
<script>
    //JavaScript代码区域
    //Demo
    layui.use(['table','form','jquery','upload','layedit'], function(){
        var form = layui.form;
        var jquery = layui.jquery;
        var upload = layui.upload;
        var layer = layui.layer;
        var table = layui.table;
        var layedit = layui.layedit;

        //普通图片上传
        upload.render({
            elem: '#test1'
            ,url: '/admin/nav/uploadLayui'
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    jquery('#demo1').attr('src', result); //图片链接（base64）
                });
            }
            ,done: function(res){
                //上传成功
                jquery('#path_name').val(res.data.src);
                console.log(jquery('#path_name').val());
            }
        });

        //监听提交
        form.on('submit(formDemo)',function(data){

            //data.field.edit = layedit.getContent(index);
            console.log(data);
            //传送数据到服务器
            jquery.post("/admin/nav/doUpdate",data.field,function(result){
                if(result.code = 1){
                    layer.msg('修改成功');
                    window.parent.location.reload();
                }
            });
            return false;
        })
    });
</script>
</body>
</html>